package cn.xuanxuanyuhua.crm.query;

import cn.xuanxuanyuhua.crm.util.DateUtil;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.util.StringUtils;

import java.util.Date;

@Setter
@Getter
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class QueryObject {
    private int currentPage = 1;
    private int pageSize = 5;

    protected String keyword;
    //排序
    private String orderBy;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date beginDate;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endDate;

    public Date getEndDate() {
        return DateUtil.getEndDate(endDate);
    }

    public String getKeyword(){
        return StringUtils.hasLength(keyword)? keyword : null;
    }
}
